<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="/js/jquery-3.5.1.js"></script>
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<style>
    html {
        filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
        -webkit-filter: grayscale(100%);
    }
</style>
<body>
<div>
    <h1>
        个人信息
    </h1>
</div>
<div>
    <table class="table">
        <tr>
            <td width="2%">&nbsp;</td>
            <td width="96%">
                <table  class="table">
                    <tr>
                        <td colspan="2">
                            <form action="" method="">
                                <table   class="table" id="tbRecord"  >
                                    <thead>
                                    <tr>
                                        <th>用户名</th>
                                        <th>会员邮箱</th>
                                        <th>身份证号</th>
                                        <th>手机号</th>
                                        <th>余额</th>
                                        <th>注销</th>
                                    </tr>
                                    </thead>
                                    <tbody id="borrowInfo">





                                    </tbody>
                                </table>

                            </form>
                        </td>
                    </tr>
                </table>
            </td>
            <td width="2%">&nbsp;</td>
        </tr>
    </table>
    <tr>

    </tr>
</div>

</body>
</html>
<script>

    var borObj;
    var cancel;//注销按钮
    var request = new XMLHttpRequest();
    var url = "/userInfo.bor";
    request.open("Get",url);
    request.onreadystatechange = function (){
        if (request.readyState==4){
            console.log(request.responseText);

            borObj = JSON.parse(request.responseText);
            for (let j = 0; j < borObj.length; j++) {
                let str = "<td>" + borObj[j].userName + "</td>";
                str += "<td>" + borObj[j].email + "</td>";
                str += "<td>" + borObj[j].idCard + "</td>";
                str += "<td>" + borObj[j].phone + "</td>";
                str += "<td>" + borObj[j].balance + "</td>";
                str += "<td><input type='button' id='cancel' onclick='cancelButton()' value='点击发送注销申请'><input type='button' onclick='cancelButton1()' value='查看'></td>";
                let tr = $("<tr>" + str + "</tr>");
                $("#borrowInfo").append(tr);
                cancel = document.getElementById("cancel");
            }
        }
    }
    request.send(null);

    function cancelButton(){
        confirm("注销申请已提交");
        cancel.value="管理员审核中";
        let request1 = new XMLHttpRequest();
        let url = "/cancel.bor?isCancel=1";
        request1.open("Get",url);
        request1.onreadystatechange = function (){
            if (request1.readyState==4){
                console.log(request1.responseText)
            }
        }
        request1.send(null);
        cancel.disabled=true;
    }

    function cancelButton1(){
        url = "/userInfo.bor";
        request.open("Get",url);
        request.onreadystatechange = function (){
            if (request.readyState==4){
                console.log(request.responseText)
                borObj = JSON.parse(request.responseText);
                console.log(borObj)
                console.log(borObj[0].isCancel)
                if (borObj[0].isCancel=="2"){
                    confirm("您的账号已注销");
                    window.location.reload();
                }else if (borObj[0].isCancel=="1"){
                    confirm("管理员审核中,请稍后查看")
                }else if (borObj[0].isCancel=="3"){
                    confirm("管理员拒绝了您的注销操作，详情请联系管理员")
                }
            }
        }
        request.send(null);
    }



</script>